#include"lars_api.h"

// 开发者业务模块
int main(int argc, char* argv[]){
    if(argc != 3){
        printf("usage: ./get_host [modid] [cmdid]\n");
        return 1;
    }

    int modid = atoi(argv[1]);
    int cmdid = atoi(argv[2]);

    lars_client client;
    std::string ip;
    int port;
    int ret = client.reg_init(modid, cmdid);
    if(ret == 0){
        fprintf(stderr, "reg_init succ:%d\n",ret);
    }
    else if(ret == 2){
        fprintf(stderr, "system error:%d\n",ret);
    }
    else if(ret == 3){
        fprintf(stderr, "data is not exist:%d\n",ret);
    }

    ret = client.get_host(modid, cmdid, ip, port);
    if(ret == 0){
        printf("host data : ip:%s port:%d\n", ip.c_str(), port);
        
        // 获得IP和port，根据IP和port做业务
        
        
        // 根据之前之前host使用的情况上报对应的host情况
        client.report_host(modid, cmdid, ip, port, 0);

    }

    return 0;
}
